package com.hq.fxh.CustomerView;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.hq.fxh.Utils.LogUtils;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/9/26
 * @Email xlwenhao1858@sina.com
 */


public class MyRecycle extends RecyclerView {

    private float xLast;
    private float yLast;
    private float xDistance;
    private float yDistance;

    public MyRecycle(Context context) {
        super(context);
    }

    public MyRecycle(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecycle(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {

        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                LogUtils.w("fffffffffffff---------MyRecycle  ACTION_DOWN11111111111111111111111111111111");

                xDistance = yDistance = 0f;
                xLast = ev.getX();
                yLast = ev.getY();
                break;
            case MotionEvent.ACTION_MOVE:
                LogUtils.w("fffffffffffffff-----MyRecycle  ACTION_MOVE222222222222222222222222222222");

                final float curX = ev.getX();
                final float curY = ev.getY();

                xDistance += Math.abs(curX - xLast);
                yDistance += Math.abs(curY - yLast);
                xLast = curX;
                yLast = curY;

                if (xDistance > yDistance) {
                    LogUtils.w("ffffffffffff---------MyRecycle  false3333333333333333333333333");

                    return false;
                }
        }
        return super.onInterceptTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent e) {

        return super.onTouchEvent(e);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {

        return super.dispatchTouchEvent(ev);
    }

}
